package guojin.sqlsession;

import guojin.config.XMLConfigBuilder;
import guojin.pojo.Configeration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;



/**
 * @author haoge
 * @version $Id SqlSessionFactorytionBuilder.java, v 0.1 2021-06-09 21:50 haoge Exp $$
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream in) throws PropertyVetoException, DocumentException {
        //用log4j解析数据源和sql配置文件
        XMLConfigBuilder xmlConfigration = new XMLConfigBuilder();
        Configeration configeration = xmlConfigration.parseConfig(in);
        //创建工厂生产sqlsession会话
        DefaultSqlsessionFactory defaultSqlsessionFactory = new DefaultSqlsessionFactory(configeration);
        return defaultSqlsessionFactory;

    }


}
